package ru.myrtle.umf.impl;

import java.util.*;
import ru.myrtle.umf.*;
import ru.myrtle.umf.util.*;

public class UEnumerationImpl extends UObjectImpl implements UEnumeration {

    protected static final boolean SERIALIZABLE_DEFAULT = Boolean.FALSE;
    protected static final UConverter CONVERTER_DEFAULT = null;
    protected static final String INSTANCE_CLASS_NAME_DEFAULT = null;
    protected static final String NAME_DEFAULT = null;
    protected static final String DESCRIPTION_DEFAULT = null;

    public UEnumerationImpl() {
    }

    @Override
    public UClass uClass() {
        return UModel.UENUMERATION;
    }
    
    private UList<UEnumerationLiteral> _literals_;

    @Override
    public final UList<UEnumerationLiteral> getLiterals() {
        if (_literals_ == null) {
            _literals_ = new UObjectContainmentWithInverseList<UEnumerationLiteral>(this, UModel.UENUMERATION__LITERALS, UModel.UENUMERATION_LITERAL__ENUMERATION);
        }
        return _literals_;
    }

    @Override
    public final boolean isSetLiterals() {
        return _literals_ != null && !_literals_.isEmpty();
    }

    @Override
    public void setLiterals(UList<UEnumerationLiteral> _literals_) {
        getLiterals().clear();
        getLiterals().addAll(_literals_);
    }

    @Override
    public void unsetLiterals() {
        if (_literals_ != null) {
            _literals_.clear();
        }
    }

    private boolean _serializable_ = SERIALIZABLE_DEFAULT;

    @Override
    public final boolean isSerializable() {
        return _serializable_;
    }

    @Override
    public final boolean isSetSerializable() {
        return _serializable_ != SERIALIZABLE_DEFAULT;
    }

    @Override
    public final void setSerializable(boolean _serializable_) {
        this._serializable_ = _serializable_;
    }

    @Override
    public final void unsetSerializable() {
        _serializable_ = SERIALIZABLE_DEFAULT;
    }

    private UConverter _converter_ = CONVERTER_DEFAULT;

    @Override
    public final UConverter getConverter() {
        return _converter_;
    }

    @Override
    public final boolean isSetConverter() {
        return _converter_ != CONVERTER_DEFAULT;
    }

    @Override
    public final void setConverter(UConverter _converter_) {
        this._converter_ = _converter_;
    }

    @Override
    public final void unsetConverter() {
        _converter_ = CONVERTER_DEFAULT;
    }

    private UPackage _package_;

    @Override
    public final UPackage getPackage() {
        return _package_;
    }

    @Override
    public final boolean isSetPackage() {
        return _package_ != null;
    }

    private void setPackageImpl(UPackage _package_) {
        this._package_ = _package_;
    }

    private UList<UOperation> _operations_;

    @Override
    public final UList<UOperation> getOperations() {
        if (_operations_ == null) {
            _operations_ = new UObjectContainmentWithInverseList<UOperation>(this, UModel.UCLASSIFIER__OPERATIONS, UModel.UOPERATION__CONTAINING_CLASSIFIER);
        }
        return _operations_;
    }

    @Override
    public final boolean isSetOperations() {
        return _operations_ != null && !_operations_.isEmpty();
    }

    @Override
    public void setOperations(UList<UOperation> _operations_) {
        getOperations().clear();
        getOperations().addAll(_operations_);
    }

    @Override
    public void unsetOperations() {
        if (_operations_ != null) {
            _operations_.clear();
        }
    }

    private String _instanceClassName_ = INSTANCE_CLASS_NAME_DEFAULT;

    @Override
    public final String getInstanceClassName() {
        return _instanceClassName_;
    }

    @Override
    public final boolean isSetInstanceClassName() {
        return _instanceClassName_ != INSTANCE_CLASS_NAME_DEFAULT;
    }

    @Override
    public final void setInstanceClassName(String _instanceClassName_) {
        this._instanceClassName_ = _instanceClassName_;
    }

    @Override
    public final void unsetInstanceClassName() {
        _instanceClassName_ = INSTANCE_CLASS_NAME_DEFAULT;
    }

    @Override
    public final Class getInstanceClass() {
        return UEnumerationOperations.INSTANCE.getInstanceClass(this);
    }

    @Override
    public final boolean isSetInstanceClass() {
        return UEnumerationOperations.INSTANCE.isSetInstanceClass(this);
    }

    @Override
    public final void setInstanceClass(Class _instanceClass_) {
        UEnumerationOperations.INSTANCE.setInstanceClass(this, _instanceClass_);
    }

    @Override
    public final void unsetInstanceClass() {
        UEnumerationOperations.INSTANCE.unsetInstanceClass(this);
    }
    
    @Override
    public final String getInstanceTypeName() {
        return UEnumerationOperations.INSTANCE.getInstanceTypeName(this);
    }

    @Override
    public final boolean isSetInstanceTypeName() {
        return UEnumerationOperations.INSTANCE.isSetInstanceTypeName(this);
    }

    @Override
    public final void setInstanceTypeName(String _instanceTypeName_) {
        UEnumerationOperations.INSTANCE.setInstanceTypeName(this, _instanceTypeName_);
    }

    @Override
    public final void unsetInstanceTypeName() {
        UEnumerationOperations.INSTANCE.unsetInstanceTypeName(this);
    }
    
    @Override
    public final Object getDefaultValue() {
        return UEnumerationOperations.INSTANCE.getDefaultValue(this);
    }

    @Override
    public final boolean isSetDefaultValue() {
        return UEnumerationOperations.INSTANCE.isSetDefaultValue(this);
    }

    private String _name_ = NAME_DEFAULT;

    @Override
    public final String getName() {
        return _name_;
    }

    @Override
    public final boolean isSetName() {
        return _name_ != NAME_DEFAULT;
    }

    @Override
    public final void setName(String _name_) {
        this._name_ = _name_;
    }

    @Override
    public final void unsetName() {
        _name_ = NAME_DEFAULT;
    }

    private String _description_ = DESCRIPTION_DEFAULT;

    @Override
    public final String getDescription() {
        return _description_;
    }

    @Override
    public final boolean isSetDescription() {
        return _description_ != DESCRIPTION_DEFAULT;
    }

    @Override
    public final void setDescription(String _description_) {
        this._description_ = _description_;
    }

    @Override
    public final void unsetDescription() {
        _description_ = DESCRIPTION_DEFAULT;
    }

    private UList<UAnnotation> _annotations_;

    @Override
    public final UList<UAnnotation> getAnnotations() {
        if (_annotations_ == null) {
            _annotations_ = new UObjectContainmentList<UAnnotation>(this, UModel.UELEMENT__ANNOTATIONS);
        }
        return _annotations_;
    }

    @Override
    public final boolean isSetAnnotations() {
        return _annotations_ != null && !_annotations_.isEmpty();
    }

    @Override
    public void setAnnotations(UList<UAnnotation> _annotations_) {
        getAnnotations().clear();
        getAnnotations().addAll(_annotations_);
    }

    @Override
    public void unsetAnnotations() {
        if (_annotations_ != null) {
            _annotations_.clear();
        }
    }


    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public Object uGet(UFeature feature) {
        if (feature == UModel.UENUMERATION__LITERALS) {
            return getLiterals();
        }
        if (feature == UModel.UDATA_TYPE__SERIALIZABLE) {
            return isSerializable();
        }
        if (feature == UModel.UDATA_TYPE__CONVERTER) {
            return getConverter();
        }
        if (feature == UModel.UCLASSIFIER__PACKAGE) {
            return getPackage();
        }
        if (feature == UModel.UCLASSIFIER__OPERATIONS) {
            return getOperations();
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_CLASS_NAME) {
            return getInstanceClassName();
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_CLASS) {
            return getInstanceClass();
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_TYPE_NAME) {
            return getInstanceTypeName();
        }
        if (feature == UModel.UCLASSIFIER__DEFAULT_VALUE) {
            return getDefaultValue();
        }
        if (feature == UModel.UELEMENT__NAME) {
            return getName();
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            return getDescription();
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            return getAnnotations();
        }

        return super.uGet(feature);
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public boolean uIsSet(UFeature feature) {
        if (feature == UModel.UENUMERATION__LITERALS) {
            return isSetLiterals();
        }
        if (feature == UModel.UDATA_TYPE__SERIALIZABLE) {
            return isSetSerializable();
        }
        if (feature == UModel.UDATA_TYPE__CONVERTER) {
            return isSetConverter();
        }
        if (feature == UModel.UCLASSIFIER__PACKAGE) {
            return isSetPackage();
        }
        if (feature == UModel.UCLASSIFIER__OPERATIONS) {
            return isSetOperations();
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_CLASS_NAME) {
            return isSetInstanceClassName();
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_CLASS) {
            return isSetInstanceClass();
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_TYPE_NAME) {
            return isSetInstanceTypeName();
        }
        if (feature == UModel.UCLASSIFIER__DEFAULT_VALUE) {
            return isSetDefaultValue();
        }
        if (feature == UModel.UELEMENT__NAME) {
            return isSetName();
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            return isSetDescription();
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            return isSetAnnotations();
        }

        return super.uIsSet(feature);
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uSet(UFeature feature, Object value) {
        if (feature == UModel.UENUMERATION__LITERALS) {
            setLiterals((UList<UEnumerationLiteral>) value);
            return;
        }
        if (feature == UModel.UDATA_TYPE__SERIALIZABLE) {
            setSerializable(((Boolean) value).booleanValue());
            return;
        }
        if (feature == UModel.UDATA_TYPE__CONVERTER) {
            setConverter((UConverter) value);
            return;
        }
        if (feature == UModel.UCLASSIFIER__OPERATIONS) {
            setOperations((UList<UOperation>) value);
            return;
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_CLASS_NAME) {
            setInstanceClassName((String) value);
            return;
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_CLASS) {
            setInstanceClass((Class) value);
            return;
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_TYPE_NAME) {
            setInstanceTypeName((String) value);
            return;
        }
        if (feature == UModel.UELEMENT__NAME) {
            setName((String) value);
            return;
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            setDescription((String) value);
            return;
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            setAnnotations((UList<UAnnotation>) value);
            return;
        }

        super.uSet(feature, value);
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uUnset(UFeature feature) {
        if (feature == UModel.UENUMERATION__LITERALS) {
            unsetLiterals();
            return;
        }
        if (feature == UModel.UDATA_TYPE__SERIALIZABLE) {
            unsetSerializable();
            return;
        }
        if (feature == UModel.UDATA_TYPE__CONVERTER) {
            unsetConverter();
            return;
        }
        if (feature == UModel.UCLASSIFIER__OPERATIONS) {
            unsetOperations();
            return;
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_CLASS_NAME) {
            unsetInstanceClassName();
            return;
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_CLASS) {
            unsetInstanceClass();
            return;
        }
        if (feature == UModel.UCLASSIFIER__INSTANCE_TYPE_NAME) {
            unsetInstanceTypeName();
            return;
        }
        if (feature == UModel.UELEMENT__NAME) {
            unsetName();
            return;
        }
        if (feature == UModel.UELEMENT__DESCRIPTION) {
            unsetDescription();
            return;
        }
        if (feature == UModel.UELEMENT__ANNOTATIONS) {
            unsetAnnotations();
            return;
        }

        super.uUnset(feature);
    }


    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uInternalInverseAdd(UObject otherEnd, UReference reference) {
        if (reference == UModel.UENUMERATION__LITERALS) {
            ((UObjectList<UEnumerationLiteral>) getLiterals()).basicAdd((UEnumerationLiteral) otherEnd);
            return;
        }
        if (reference == UModel.UCLASSIFIER__PACKAGE) {
            setPackageImpl((UPackage) otherEnd);
            return;
        }
        if (reference == UModel.UCLASSIFIER__OPERATIONS) {
            ((UObjectList<UOperation>) getOperations()).basicAdd((UOperation) otherEnd);
            return;
        }
    }

    @Override
    @SuppressWarnings(
        "unchecked"
    )
    public void uInternalInverseRemove(UObject otherEnd, UReference reference) {
        if (reference == UModel.UENUMERATION__LITERALS) {
            ((UObjectList<UEnumerationLiteral>) getLiterals()).basicRemove((UEnumerationLiteral) otherEnd);
            return;
        }
        if (reference == UModel.UCLASSIFIER__PACKAGE) {
            setPackageImpl(null);
            return;
        }
        if (reference == UModel.UCLASSIFIER__OPERATIONS) {
            ((UObjectList<UOperation>) getOperations()).basicRemove((UOperation) otherEnd);
            return;
        }
    }


    @Override
    public UEnumerationLiteral getLiteralByName(String name) {
        return UEnumerationOperations.INSTANCE.getLiteralByName(this, name);
    }

    @Override
    public boolean isInstance(Object object) {
        return UEnumerationOperations.INSTANCE.isInstance(this, object);
    }

    @Override
    public String toString() {
        StringBuffer result = new StringBuffer();

        result.append("UEnumeration");
        result.append(" (");
        result.append("serializable: ");
        result.append(_serializable_);
        result.append(", ");
        result.append("converter: ");
        result.append(_converter_);
        result.append(", ");
        result.append("instanceClassName: ");
        result.append(_instanceClassName_);
        result.append(", ");
        result.append("name: ");
        result.append(_name_);
        result.append(", ");
        result.append("description: ");
        result.append(_description_);
        result.append(')');

        return result.toString();
    }
}




